﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace GameEditor.Common.InternalDialogs
{
    partial class PropertyDialog : Form
    {
        public PropertyDialog()
        {
            InitializeComponent();
        }

        public DelegateWithReturnValue<bool, object> Validation
        {
            get;
            set;
        }

        public object PropertySet
        {
            get { return propertyGrid1.SelectedObject; }
            set 
            { 
                propertyGrid1.SelectedObject = value;
                if (value != null && value is IPropertyInspectable)
                {
                    (value as IPropertyInspectable).OnInspect(propertyGrid1);
                }
            }
        }


        private void OnOK(object sender, EventArgs e)
        {
            if (Validation(PropertySet) == false)
                return;
            DialogResult = DialogResult.OK;
        }
    }


}
namespace GameEditor.Common
{

    public interface IPropertyInspectable
    {
        void OnInspect(PropertyGrid propertyGrid);
    }
}